package com.bugstack.domain.strategy.repository;

import com.bugstack.domain.strategy.model.entity.StrategyAwardEntity;
import com.bugstack.domain.strategy.model.entity.StrategyEntity;
import com.bugstack.domain.strategy.model.entity.StrategyRuleEntity;
import com.bugstack.domain.strategy.model.vo.RuleTreeVO;
import com.bugstack.domain.strategy.model.vo.RuleWeightVO;
import com.bugstack.domain.strategy.model.vo.StrategyAwardRuleModelVO;
import com.bugstack.domain.strategy.model.vo.StrategyAwardStockKeyVO;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * @Author: czb
 * @Description: 策略仓储服务
 * @DateTime: 2025/3/3 16:48
 **/
public interface IStrategyRepository {

    List<StrategyAwardEntity> queryStrategyAwardList(Long strategyId);

    void storeStrategyAwardSearchTables(String key, Integer rateRange, HashMap<Integer, Integer> shuffleStrategyAwardSearchTables);

    Integer getRateRange(Long strategyId);

    Integer getRateRange(String key);

    Integer getStrategyAwardAssemble(String key, int rateKey);

    StrategyEntity queryStrategyById(Long strategyId);

    StrategyRuleEntity queryStrategyRule(Long strategyId, String ruleModel);

    String queryStrategyRuleValue(Long strategyId, Integer awardId, String ruleModel);

    String queryStrategyRuleValue(Long strategyId, String ruleModel);

    StrategyAwardRuleModelVO queryStrategyAwardRuleModelVO(Long strategyId, Integer awardId);

    RuleTreeVO queryRuleTreeVOByTreeId(String treeId);

    void cacheStrategyAwardCount(String cacheKey, Integer awardCount);

    boolean subtractionAwardStock(String cacheKey, Date endDateTime);

    void awardStockConsumeSendQueue(StrategyAwardStockKeyVO strategyAwardStockKeyVO);

    StrategyAwardStockKeyVO takeQueueValue();

    void updateStrategyAwardStock(Long strategyId, Integer awardId);

    List<StrategyAwardEntity> queryRaffleStrategyAwardList(Long strategyId);

    StrategyAwardEntity queryStrategyAwardEntity(Long strategyId, Integer awardId);

    Long queryStrategyIdByActivityId(Long activityId);

    Integer queryDayRaffleCount(String userId, Long strategyId);

    Map<String, Integer> queryAwardRuleLockCount(String[] treeIds);

    List<RuleWeightVO> queryAwardRuleWeight(Long strategyId);

    Integer queryActivityAccountTotalUseCount(String userId, Long strategyId) throws ExecutionException, InterruptedException;

    List<StrategyAwardStockKeyVO> queryOpenActivityStrategyAwardList();

    StrategyAwardStockKeyVO takeQueueValue(Long strategyId, Integer awardId) throws InterruptedException;
}
